package com.mz.ozy.mvp.presenter;

import android.content.Context;

import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.bean.VipRecordBean;
import com.mz.ozy.mvp.model.VipRecordModel;
import com.mz.ozy.mvp.view.VipRecordContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import org.json.JSONObject;

import okhttp3.ResponseBody;


public class VipRecordPresenter extends BasePresenterImpl<VipRecordContract.View> implements VipRecordContract.Presenter {

    private VipRecordModel mModel;


    public VipRecordPresenter() {
        mModel = new VipRecordModel();
    }

    @Override
    public void getList(Context context, String pageSize) {
        mModel.getList(context, pageSize)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<VipRecordBean>(mView) {

                    @Override
                    public void onSuccesss(VipRecordBean bean) {
                        mView.getListSuccess(bean);
                    }
                });
    }

    @Override
    public void cancleOrder(Context context, String tesq) {
        mModel.cancleOrder(context, tesq)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<JSONObject>(mView) {

                    @Override
                    public void onSuccesss(JSONObject bean) {
                        mView.cancleOrderSuccess(bean);
                    }
                });
    }

    @Override
    public void onPayOrder(Context context, String tesq) {
        mModel.onPayOrder(context, tesq)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<JSONObject>(mView) {

                    @Override
                    public void onSuccesss(JSONObject bean) {
                        mView.onPayOrderSuccess(bean);
                    }
                });
    }
}
